#  include  <stdio.h>
int isprime(int a);
int main (){
    int i,a,b,j,sum=0;
    scanf("%d %d",&a,&b);
    for(i=0,j=2;i<b;j++){
      if(isprime(j)){i++; 
		if(i>=a){
		  sum+=j;
		}
	}
}	printf("%d",sum);
	return 0;
} 
 int isprime(int a){
 	int i,ret=0;
 	if(a==2){ret=1;
	 }else{
	 	if(a%2==0){ret=0;
		 }else{ret=1;
		 	for(i=3;i<a;i+=2){
		 		if(a%i==0){ret=0;break;
				 }
			 } 
		 }
	 }
	 return ret;
 }
